/*
2022-5-1
https://www.acwing.com/problem/content/4418/
*/ 

#include<cstring>
#include<iostream>
#include<algorithm>

using namespace std;

const int N=3e5+10,M=2*N,mod=998244353;
int h[N],e[M],ne[M],idx,col[N];
int s1,s2;
int T,n,m;
int a,b;
int res;

void add(int a,int b)
{
    e[idx]=b,ne[idx]=h[a],h[a]=idx++;
}

int power2(int x)
{
    long long res=1;
    int a=2;
    while(x)
    {
        if(x&1) res=(long long)res*a%mod;
        a=(long long)a*a%mod;
        x/=2;
    }
    return res;
}

int dfs(int u,int color)
{
    col[u]=color;
    if(color==1) s1++;
    else s2++;
    for(int i=h[u];i!=-1;i=ne[i])
    {
        int j=e[i];
        if(col[j]&&col[j]!=3-color) return false;
        if(!col[j])
        {
            if(!dfs(j,3-color)) return false;
        }
    }
    return true;
}

int main()
{
    cin>>T;
    while(T--)
    {
        cin>>n>>m;
        memset(h,-1,4*n+4);
        memset(col,0,4*n+4);
        idx=0;
        
        for(int i=0;i<m;i++)
        {
            cin>>a>>b;
            add(a,b),add(b,a);
        }
        res=1;
        for(int i=1;i<=n;i++)
        {
            if(!col[i])
            {
                s1=s2=0;
                if(dfs(i,1)) res=(long long)res*(power2(s1)+power2(s2))%mod;
                else
                {
                    res=0;
                    break;
                }
            }
        }
        cout<<res<<endl;
        
    }
    return 0;
}
